"""
1)切换到iframe中 switch_to.frame(i)
2）切换到上一层  switch_to.parent_frame()
3）切换到默认层（最外层） switch_to.default_content()
"""

import time

from  selenium import webdriver
from  selenium.webdriver.common.by import By

# 获取驱动
driver = webdriver.Edge()
# 通过驱动打开网页
driver.get("http://127.0.0.1/ranzhi/www")
time.sleep(1)

# 登录
driver.find_element("id","account").send_keys("admin")
driver.find_element("id","password").send_keys("123456")
driver.find_element("id","submit").click()
time.sleep(1)
# 点击后台按钮
driver.find_element("id","s-menu-superadmin").click()


# 获取iframe标签
i = driver.find_element("id","iframe-superadmin")
# 切换到iframe
driver.switch_to.frame(i)
time.sleep(1)
# 点击添加成员
driver.find_element("class name","shortcut.user").click()
time.sleep(2)

# 切换到上一层
# driver.switch_to.parent_frame()
# 切换到最外层
driver.switch_to.default_content()

# 签退
driver.find_element("link text","签退").click()
time.sleep(10)



